#!/bin/bash
#*****************************************************************************
# Protected
# Copyright AUBASS CO., LTD.
#*****************************************************************************

source ${HOME}/.bash_profile

DIR="$( cd "$( dirname "$0" )" && pwd -P )"
CUSTOM=$(find ${DIR} -name create_customize_machine.sh)
ret=$?

if [ -z ${CUSTOM} ]; then
  echo -e "\033[31;1m[ERROR] No such file 'create_customize_machine.sh'.\033[m" 1>&2
  exit 1
fi

bash ${CUSTOM} --docker-network-name=someipdemos --network-mask=192.168.111.0/24 --docker-machine-name=skeleton --ip-address=192.168.111.10 --publish=3491:3490 --publish=63400:63400/tcp --publish=13040:13040/tcp --docker-image-name=${AUBIST_AP_DOCKER_IMAGE_REPOSITORY}:${AUBIST_AP_DOCKER_IMAGE_TAG}
ret=$?

bash ${CUSTOM} --docker-network-name=someipdemos --network-mask=192.168.111.0/24 --docker-machine-name=proxy --ip-address=192.168.111.20 --publish=3492:3490 --docker-image-name=${AUBIST_AP_DOCKER_IMAGE_REPOSITORY}:${AUBIST_AP_DOCKER_IMAGE_TAG}

if [ 0 -eq ${ret} ]; then
  echo -e "\033[35m ### $(basename $0) finished. ###\033[m"
else
  echo -e "\033[35m ### $(basename $0) finished with error(ret=${ret}). ###\033[m"
  exit ${ret}
fi

exit 0
